home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
ARMLINUX
/
ISCAFS
/
ISCAFS.ZIP
/
IscaFS0-05
/
Support
/
ReadPart
(
.txt
)
Wrap
RISC OS BBC BASIC V Source
|
1998-05-28
|
4KB
|
113 lines
>ReadPart
by Phil Norman 18th November, 1997
Primitive program to read linux partitions and understand them (eventually)
$+" at line "+
init_vars
Variables that can be user-defined
discnumber% = 4
filesystem$ = "ADFS"
partition% is the partition as linux defines it - ie for /dev/hda3,
partition%=3
partition% = 3
disc_type% should be dt_long% or dt_short% depending on the version of
filecore you're using (see instructions)
disc_type%=dt_long%
Filename to save the ext2 filesystem as
outfile$="ADFS::4.$.image"
Number of sectors to read at once
sectors_at_once% = 64
Variables that are set by the OS or calculated from user-given variables
above
discname$=":"+
discnumber%
partition_addr% = &1fc+&c00
superblock_addr% = 1024
superblock_len% = 1024
Initialise FileCore stuff
wa% 4
"OS_Module",18,"FileCore%"+filesystem$
,,,,!wa%
Initialisation stuff
descriptor% &40
"FileCore_DescribeDisc",discname$,descriptor%,,,,,,,wa%
,$sector_size% = 1<<(?descriptor%)
-§ors_per_track% = descriptor%?1
heads% = descriptor%?2
table% sector_size%*2
Read the part of the FileCore partition containing the position of the linux
partition table
3?sector_base% = (partition_addr%
sector_size%)*sector_size%
41sector_offset% = partition_addr%-sector_base%
"FileCore_DiscOp",,1,sector_base%+(discnumber%<<29),table%,sector_size%,,,,wa%
,,,,unread%
unread%
unread%+" not read."
8&format_id% = table%?sector_offset%
format_id%
:Mstart_cyl% = (table%?(sector_offset%+1))+((table%?(sector_offset%+2))<<8)
;8start_sector% = start_cyl%*heads%*sectors_per_track%
=#descriptor%!16 = 1024*1024*1024
Grab linux partition table
"Partition table sector : "+
~start_sector%
"Partition table address : "+
~(start_sector%*sector_size%)
read_sectors(start_sector%,2,table%)
C&tabentry%=table%+12*(partition%-3)
!tabentry%=0
0,"No such partition."
!tabentry%<>ptype_native%
0,"Partition is not linux native."
F1fs_startsector% = start_sector% + tabentry%!4
G!fs_numsectors% = tabentry%!8
" start sector : "+
fs_startsector%
" end sector : "+
(fs_startsector%+fs_numsectors%-1)
Copy all the sectors in the filesystem into the given file
block% sectors_at_once%*sector_size%
file%=
(outfile$)
"Sectors to read : "+
(fs_numsectors%-1)
"Reading sector : ";
step%=sectors_at_once%
c%=0
fs_numsectors%
step%
d%=1
(fs_numsectors%-c%)<=step%
step%=2
read_sectors(fs_startsector%+c%,step%,block%)
"OS_GBPB",2,file%,block%,sector_size%*step%
#file%
Set filetype and exit
"Setting filetype..."
("settype "+outfile$+" 0b0")
"Done!"
init_vars
ptype_swap%=&deafab1e
ptype_native%=&deafa1de
dt_short%=0
dt_long%=1
read_sectors(sect%,num%,mem%)
disc_type%=dt_long%
pu
"FileCore_SectorOp",,1+(descriptor%<<6),sect%+(discnumber%<<29),mem%,num%*sector_size%,,,,wa%
,,,,unread%
r*
(sect%*sector_size%)
&e0000000
sc
"Error in PROCread_sectors: Your version of FileCore cannot read this far into a disc."
u
"FileCore_DiscOp",,1+(descriptor%<<6),sect%*sector_size%+(discnumber%<<29),mem%,num%*sector_size%,,,,wa%
,,,,unread%
w
unread%
"Warning in PROCread_sectors: "+
unread%+" bytes not read."